package zigzag.designpattern.adapter;

public class User {
	private String userID;
	private String userPwd;
	private String userPostcode;
	private static String userChina = "CHINA";
	private static String userUsa = "USA";
	public String getUserID() {
		return userID;
	}
	public void setUserID(String userID) {
		this.userID = userID;
	}
	public String getUserPwd() {
		return userPwd;
	}
	public void setUserPwd(String userPwd) {
		this.userPwd = userPwd;
	}
	public String getUserPostcode() {
		return userPostcode;
	}
	public void setUserPostcode(String userPostcode) {
		this.userPostcode = userPostcode;
	}

	public boolean checkPostcode(){
		PostcodeValidator vld = getValidator(userPostcode);
		if (vld==null) return false;
		return vld.isPoatcodeCorrect(userPostcode);
		
	}
	
	public PostcodeValidator getValidator(String userType){
		PostcodeValidator vld = null;
		if (userType == User.userChina){
			vld = new ChinaPostcode();
		}
		
		if (userType== User.userUsa){
			vld = new UsaPostcodeAdapter();
		}
		return vld;
	}

}
